package com.coscon.test;

import org.apache.shiro.codec.Base64;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class ShiroCustomAESKeyUtil {

    /**
     * 生成密钥
     *
     * @return
     * @throws Exception
     */
    public static String getKey() throws Exception {
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        SecretKey deskey = keygen.generateKey();
        String key = Base64.encodeToString(deskey.getEncoded());
        return key;
    }
    public static void main(String[] args) throws Exception {
        System.out.println(getKey());
    }


}
